package com.csce.domain.entity.go_score;

import com.csce.domain.entity.score.ScoreSheet;
import com.csce.domain.entity.score.ScoreSheetStep;
import com.osce.common.annotation.Excel;
import com.osce.common.core.entity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 妇产科考试考场学生-分数对象 go_score_ex_exam_score
 *
 * @author zzx
 * @since 2024-05-17
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
@ToString
@EqualsAndHashCode(callSuper = true)
public class GoScoreExExamMark extends BaseEntity {

    private static final long serialVersionUID = 1L;

    private Long id;

    /**
     * 考试编号
     */
    @Excel(name = "考试编号")
    @ApiModelProperty("考试编号")
    private Long examId;

    /**
     * 考试考站编号
     */
    @Excel(name = "考试考站编号")
    @ApiModelProperty("考试考站编号")
    private Long examPlaceId;

    /**
     * 考试考场学生编号
     */
    @Excel(name = "考试考场学生编号")
    @ApiModelProperty("考试考场学生编号")
    private Long examStudentId;

    /**
     * 评分表编号
     */
    @Excel(name = "评分表编号")
    @ApiModelProperty("评分表编号")
    private Long sheetId;

    /**
     * 总分
     */
    @Excel(name = "总分")
    @ApiModelProperty("总分")
    private BigDecimal score;


    /**
     * 评语
     */
    @Excel(name = "评语")
    @ApiModelProperty("评语")
    private String comment;

    private ScoreSheet scoreSheet;

    private List<GoScoreExExamScore> goScoreExExamScores;

    public GoScoreExExamMark copy(){
        GoScoreExExamMark goScoreExExamMark = new GoScoreExExamMark();
        goScoreExExamMark.setId(this.id);
        goScoreExExamMark.setExamId(this.examId);
        goScoreExExamMark.setExamPlaceId(this.examPlaceId);
        goScoreExExamMark.setExamStudentId(this.examStudentId);
        goScoreExExamMark.setSheetId(this.getSheetId());
        goScoreExExamMark.setScore(this.score);
        goScoreExExamMark.setComment(this.comment);
        return goScoreExExamMark;
    }

    /**
     * 首次创建时用的方法，需要外部传入步骤集合
     * @param steps 步骤集合
     */
    public GoScoreExExamMark createScores(List<ScoreSheetStep> steps){
        this.goScoreExExamScores = steps.stream().map(ScoreSheetStep::createGoScoreExExamScore).collect(Collectors.toList());
        return this;
    }

    /**
     * 前端传进来后使用的方法，使用自身的步骤集合
     */
    public GoScoreExExamMark createScores(){
        return createScores(this.scoreSheet.getSteps());
    }

}
